package com.study.d027shape2d;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.effect.BlendMode;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Paint;
import javafx.scene.shape.Line;
import javafx.scene.shape.StrokeLineJoin;
import javafx.scene.shape.StrokeType;
import javafx.stage.Stage;

/** 线段
*@description
*@author xtayhame
*date 2020年3月21日
*version
*since v1.0
*/
public class LineMain extends Application{
	public static void main(String[] args) {
		launch(args);
	}
	@Override
	public void start(Stage stage) throws Exception {
		AnchorPane anchorPane = new AnchorPane();
		VBox box = new VBox(10);

		Line l1 = new Line(0, 0, 300, 0);
		//设置效果
		//l1.setBlendMode(BlendMode.DARKEN);
		//设置线的宽度
		l1.setStrokeWidth(20);
		//设置
		//l1.setStrokeType(StrokeType.CENTERED);

		l1.setStrokeMiterLimit(2);

		l1.setStrokeDashOffset(4);

		l1.getStrokeDashArray().addAll(5.0,10.0,15.0,20.0);

		//l1.setStrokeLineJoin(StrokeLineJoin.MITER);

		l1.setSmooth(false);

		//设置为虚线
		Line l2 = new Line(0, 0, 300, 0);
		l2.getStrokeDashArray().addAll(5.0,10.0,15.0,20.0);
		l2.setStrokeWidth(5);
		//设置颜色
		l2.setStroke(Paint.valueOf("#8A2BE2"));

		box.getChildren().addAll(l1,l2);
		anchorPane.getChildren().add(box);
		AnchorPane.setTopAnchor(box, 30.0);
		stage.setScene(new Scene(anchorPane, 800, 500));
		stage.show();
	}
}
